import {defineStore} from 'pinia'

export const useUserInfoStore = defineStore('userInfo', {
    state: () => {
        return {
            departmentId: '',
            isDelete: 0,
            isRole: 0,
            levelId: '',
            positionId: '',
            projectId: 0,
            statusId: '',
            userAccount: '',
            userAvatarUrl: '',
            userCreateTime: '',
            userEmail: '',
            userEntryTime: '',
            userGender: 0,
            userId: 0,
            userName: '',
            userPassword: '',
            userPhone: '',
            userUpdateTime: ''
        }
    },
    getters: {},
    actions: {
        getUserImage() {
            return this.userAvatarUrl ? this.userAvatarUrl : 'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png'
        },
        loginUser(userAccount: string, userPassword: string) {
            this.userAccount = userAccount
            this.userPassword = userPassword
            sessionStorage.setItem('token', this.userId.toString())
            sessionStorage.setItem("time", (new Date().getTime() - 7200).toString())
        },
        setUserName(userAccount: string) {
            this.userAccount = userAccount
        },
        setUserimage(userAvatarUrl: string) {
            this.userAvatarUrl = userAvatarUrl
        }

    }

})
